home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / 0141ter2.zip / 0141TER2._XE / PASCAL.EXE / FILESBBS.PAS next >
Pascal/Delphi Source File  |  1993-09-23  |  4KB  |  99 lines

  1.  {
  2.  Terminate help file
  3.  
  4.  The format of FILES.BBS style files are used on many BBS systems. It is
  5.  the easiest to have around since you can edit these files with any normal
  6.  texteditor.
  7.  
  8.  Terminate will also internally support a description file called
  9.  DESCRIPT.ION, which is used together with 4DOS.
  10.  These files are real simple to process, because the format is:
  11.  filename.ext+space+description:
  12.  
  13.  Example DESCRIPT.ION file:
  14.  
  15.  ------- CUT -------
  16.  TER100.ARJ The final terminal version 1.00
  17.  T-UTILS.ARJ List & Qedit, great lister and editor
  18.  ------- CUT -------
  19.  
  20.  The FILES.BBS file is a normal textfile, which has a #13+#10 CR+LF after
  21.  each line. The following is a sample FILES.BBS.
  22.  
  23.  ------- CUT -------
  24.  ╒═══════════════════════════════════════════════════════════════════════════╕
  25.  │ Area #2  :   TER  :Terminate                          Access level    500 │
  26.  ├───────────────────────────────────────────────────────────────────────────┤
  27.  │░░░░░▒▒▒▒▒▓▓▓▓▓█████    1.192.915 bytes in    31 files █████▓▓▓▓▓▒▒▒▒▒░░░░░│
  28.  ╘ <FAST 6.00α>                                              (C) Bo Bendtsen ╛
  29.  
  30. TER99.ARJ    [429] Latest version of terminate, MAJOR UPDATE
  31.              This program will do it all for you
  32. HISTORY.DOC  [49] Check this for new features, also in TER??.ARJ
  33. -------- CUT -------
  34.  1            14
  35.  Filename     Description
  36.  
  37.  When scanning through this file you can assume that the line is a comment
  38.  if position 1 is a blank ' ' or a minus '-' then you are sure. But otherwise
  39.  you could also demand that position 1 must be in the range of 'A'..'Z', but
  40.  this method is not recommend because not all FILES.BBS programmers do the
  41.  same thing. Position 14 and the rest of the line is the description of the
  42.  file. Some programmers allow multiline descriptions, if you want to support
  43.  that, when you get a filename, just read on until a new filename is read,
  44.  the first position is minus,'',eof.
  45.  }
  46.  
  47.  { This little example will show you how to only write out files and desc. }
  48.  
  49.  {DUMMY}
  50.  
  51. Program ShowFiles;
  52.  
  53. Uses Crt;
  54.  
  55. Var
  56.   S          : String;
  57.   ReadNext   : Boolean;
  58.   FilesBBS   : Text;
  59.   FastBuffer : Array[1..8192] of Byte {or Char... does not matter};
  60.   {
  61.   8192 bytes should always be used since average size never is more than
  62.   this. Now the entire textfile will be read in one stroke.
  63.   }
  64.  
  65. Begin
  66.   ClrScr;                                        { Clear Screen             }
  67.   Filemode:=66+128;                              { Deny none on networks    }
  68.   Assign(FilesBBS,'FILESBBS.PAS');               { Only for testing         }
  69.   SetTextBuf(FilesBBS,FastBuffer);               { Set big buffer for text  }
  70.   {$I-} Reset(FilesBBS); {$I+}                   { Open the file            }
  71.   S:='';                                         { Clean string             }
  72.   If IOResult=0 Then                             { File open for read       }
  73.   Begin
  74.     ReadNext:=True;                              { Need this for multi desc.}
  75.     While Not Eof(FilesBBS) And
  76.           (S<>' {DUMMY}') Do                     { DUMMY is just to stop    }
  77.     Begin
  78.       If ReadNext Then ReadLn(FilesBBS,S);
  79.       ReadNext:=True;
  80.       If (S<>'') And                             { This is a file           }
  81.          Not (S[1] in [' ','-']) Then
  82.       Begin
  83.         WriteLn(S);                              { Show first line          }
  84.         ReadLn(FilesBBS,S);                      { Read next line           }
  85.         ReadNext:=False;
  86.         While (S<>'') And (S[1]=' ')
  87.               And Not Eof(FilesBBS) Do           { If more description lines}
  88.         Begin                                    { then read and show them  }
  89.           WriteLn(S);
  90.           ReadLn(FilesBBS,S);
  91.           ReadNext:=False;
  92.         End;
  93.       End;
  94.     End;
  95.     Close(FilesBBS);                             { Close file handle        }
  96.   End
  97.   Else WriteLn('Could not open file');           { Error if not found       }
  98. End.
  99.